package com.eastshop.category.dao;

import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.eastshop.category.vo.Category;

public class CategoryDao extends HibernateDaoSupport {

	// Dao层查找所有商品的分类
	public List<Category> find() {
		String hql = "from Category";
		List<Category> list = this.getHibernateTemplate().find(hql);
		if(list !=null && list.size() > 0){
			return list;
		}
		return null;
	}

	// Dao层根据id查询商品的分类
	public Category findByCid(Integer cid) {
		Category category = this.getHibernateTemplate().get(Category.class, cid);
		return category;
	}

	// Dao层删除商品的分类
	public void delete(Category category) {
		this.getHibernateTemplate().delete(category);
	}

	// Dao层保存商品的方法
	public void save(Category category) {
		this.getHibernateTemplate().save(category);
	}

	// Dao层更新商品分类的方法
	public void update(Category category) {
		this.getHibernateTemplate().update(category);
	}

}
